#include<iostream>
using namespace std;

int arr[5][5];
int r1, r2;

int main()
{
	for (int i = 0; i < 5; i++)
		for (int j = 0; j < 5; j++)
			cin >> arr[i][j];
		
	cin >> r1 >> r2;
	
	for (int j = 0; j < 5; j++)
	{
		int temp = arr[r1 - 1][j];
		arr[r1 - 1][j] = arr[r2 - 1][j];
		arr[r2 - 1][j] = temp;
	}
	
	for (int i = 0; i < 5; i++)
	{
		for (int j = 0; j < 5; j++)
			cout << arr[i][j] << " ";
		cout << endl;
	}
			
	return 0;
}
